package bitsetdemo;

import java.util.BitSet;

public class Test {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,12,2,3,9,18};
        MyBitSet myBitSet = new MyBitSet(18);
        for (int i = 0; i < array.length; i++) {
            myBitSet.set(array[i]);
        }

        for (int i = 0; i < myBitSet.elem.length; i++) {
            for (int j = 0; j < 8; j++) {
                if((myBitSet.elem[i] & (1 << j)) != 0) {
                    System.out.println(i*8+j);
                }
            }
        }
    }
    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,9,7};
        MyBitSet bitSet = new MyBitSet(18);

        for (int i = 0; i < array.length; i++) {
            bitSet.set(array[i]);
        }
        System.out.println(bitSet.getUsedSize());
        System.out.println(bitSet.get(9));
        System.out.println(bitSet.get(10));
        bitSet.reSet(9);
        System.out.println(bitSet.get(9));
    }
    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5,9,7};
        //会自己扩容
        BitSet bitSet = new BitSet();
        for (int i = 0; i < array.length; i++) {
            bitSet.set(array[i]);
        }
        System.out.println(bitSet.get(9));
    }
}
